package com.imaginaryphysics.www.simpletests;

import com.imaginaryphysics.www.simplepairs.*;

public class Pair_test{

	
	public static void main(String[] args) {
		Pair_test test = new Pair_test();	
		test.test_is_part_of_pair();
		test.test_get_partner();
		test.test_create_relationship();
		test.test_calculate_relationship();
	}
	
	
	Test one;
	Test two;
    Test three;
    
	Pair<Test> pair;
	
	Pair_test(){
		
		System.out.println("Running Pair Tests:");
		System.out.println("(I swear you can trust this completly ambigious test)");

		one = new Test(0);
		two = new Test(1);
	    three = new Test(3);	
		
		pair = new Pair<Test>(one,two);	
	}
	
	
	public void test_is_part_of_pair(){
	System.out.println();
	System.out.println("Testing is_part_of_pair:");
		if(pair.is_part_of_pair(three)){
			System.out.println("Fail");
		}else{
			if((pair.is_part_of_pair(one)) && (pair.is_part_of_pair(two))){
				System.out.println("pass");
			}	
		}
	}
	
	public void test_get_partner(){
		System.out.println();
		System.out.println("Testing return_partner:");
		if((pair.get_partner(one)==two) && (pair.get_partner(two)==one) && (pair.get_partner(three)==null)){
				System.out.println("pass");
		}
		
	}
	
	public void test_create_relationship(){
		System.out.println();
		System.out.println("Testing create_relationship:");
		System.out.println("Creating pair relationship");
		pair.create_relationship(new My_calculation(), new My_result());
		System.out.println("Pair relationship created");
		System.out.println("pass");

	}
	
	public void test_calculate_relationship(){
		System.out.println();
		System.out.println("Testing calculate:");
		System.out.println("one x: "+one.x);
		System.out.println("two x: "+two.x);
		int correct = one.x+two.x;
		System.out.println("Should return: "+correct);
		System.out.println("Running calculation");
		pair.calculate();
		My_result spoon = (My_result) pair.get_result();
		System.out.println("Returns: " + spoon.total_x);
		if (correct == spoon.total_x){
			System.out.println("pass");
		}
		
		
	}
	
	
}
